package com.lm.scau.dyb.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lm.scau.dyb.R;
import com.lm.scau.dyb.activity.base.BaseActivity;
import com.lm.scau.dyb.bean.Notice;
import com.lm.scau.dyb.utils.ViewHolderUtils;

import java.util.List;

/**
 * Function:
 * auth：liming on 2016/8/29 17:08
 * mail：liming@wxchina.com
 */
public class NoticeAdapter extends BaseAdapter {

    private List<Notice> notices;
    private BaseActivity activity;

    public NoticeAdapter(List<Notice> notices, BaseActivity activity) {
        this.notices = notices;
        this.activity = activity;
    }

    @Override
    public int getCount() {
        return notices.size();
    }

    @Override
    public Notice getItem(int position) {
        return notices.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(null==convertView){
            convertView = LayoutInflater.from(activity).inflate(R.layout.item_notice_list,parent,false);
        }
        TextView noticeName = ViewHolderUtils.get(convertView,R.id.notice_title);
        TextView noticeTime = ViewHolderUtils.get(convertView,R.id.notice_time);

        Notice notice = getItem(position);
        noticeName.setText(notice.getNoticeTitle());
        noticeTime.setText(notice.getNoticeTime());
        return convertView;
    }
}
